##################
# Angel M. Villegas-Cruz
# This file replicates the descriptive statistics in Appendix Table 2.
# 08/18/2024
##################

#Run "Replication - Main results.R"

##################
#Appendix Table 2
##################

#Selecting variables in main results
vars4 <- with(mydata, c("threat","bene_rule",
                        "ucdp_civil_war", "ucdp_bd_best",
                        "muslim", "muslim_pct",
                        "elec_demo","ln_gdppc","agree","ln_trade_share_i",
                        "ln_followers_count","ln_statuses_count",
                        "ln_friends_count","xinjiang_num"))

summary(mydata[vars4])

var_names = c("Threat",
              "Benevolent rule",
              "Civil war",
              "Battle-related deaths",
              "Muslim-majority (binary)", 
              "Muslim (pop. %)",
              "Electoral democracy",
              "Log(GDP p.c.)",
              "UN voting with China",
              "Log(Trade share with China)",
              "Log(N. of followers)",
              "Log(N. of tweets)",
              "Log(N. of friends)",
              "N. of tweets about Xinjiang")

#Produce descriptive stats table
stargazer(as.data.frame(mydata[vars4]),type="text", out = "appendix_table2.html",
          digits = 2,
          title = "Summary statistics", covariate.labels = var_names )

BROWSE("appendix_table2.html")